mike-north/professional-ts

Relative import for dtslint failing

Closed this issue · 2 comments

I've hit an issue when doing the course using the latest version of dtslint (4.1.6).

The relative import of the test declarations here:
https://github.com/mike-north/professional-ts/blob/fem/tests/types-dtslint/test.ts#L1

...will cause the dtslint tests to fail with:

ERROR: 1:52  no-relative-import-in-test  Test file should not use a relative import. Use a global import as if this were a user of the package. See: https://github.com/Microsoft/dtslint/blob/master/docs/no-relative-import-in-test.md

If I naively try an absolute import, based on the name field in package.json, it doesn't know what I'm talking about:

import { assertIsTypedArray, isITeam, ITeam } from 'professional-ts';

I've also tried variations like import { assertIsTypedArray, isITeam, ITeam } from 'professional-ts/tests/types-dtslint' but it doesn't know what professional-ts means.

If anyone else solved this issue, I'd be interested to hear.

Turning off the rule in tests/types-dtslint/tslint.json worked:

{
    "extends": "dtslint/dtslint.json",
    "rules": {
        "semicolon": false,
        "indent": [true, "tabs"],
        "no-relative-import-in-test": false
    }
}

Oh! SHould've kept watching the video instead of pausing and trying to solve myself. Mike solves this rapidly at 6:22 of https://frontendmasters.com/courses/production-typescript/writing-dtslint-assertions/ 🤦