Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(type-utils): fixed TypeOrValueSpecifier not accounting for scoped DT packages#6780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
31b4856
0da275e
d68d428
cffd1b2
a29d60d
bbd4662
d0b5e15
e97628f
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -139,7 +139,8 @@ describe('TypeOrValueSpecifier', () => { | ||
.program!.getTypeChecker() | ||
.getTypeAtLocation( | ||
services.esTreeNodeToTSNodeMap.get( | ||
(ast.body[ast.body.length - 1] as TSESTree.TSTypeAliasDeclaration) | ||
.id, | ||
Comment on lines +142 to +143 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I actually think this fixes a minor issue that is probably present in more tests - I have taken this directly out of some other tests in this repo | ||
), | ||
); | ||
expect(typeMatchesSpecifier(type, specifier, services.program!)).toBe( | ||
@@ -232,6 +233,90 @@ describe('TypeOrValueSpecifier', () => { | ||
['type Test = RegExp;', { from: 'lib', name: ['BigInt', 'Date'] }], | ||
])("doesn't match a mismatched lib specifier: %s", runTestNegative); | ||
it.each<[string, TypeOrValueSpecifier]>([ | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'typescript' }, | ||
], | ||
[ | ||
'import {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'typescript' }, | ||
], | ||
[ | ||
'import * as ts from "typescript"; type Test = ts.Node;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import * as ts from "typescript"; type Test = ts.Node;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'typescript' }, | ||
], | ||
[ | ||
'import type * as ts from "typescript"; type Test = ts.Node;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import type * as ts from "typescript"; type Test = ts.Node;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node as TsNode} from "typescript"; type Test = TsNode;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node as TsNode} from "typescript"; type Test = TsNode;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'typescript' }, | ||
], | ||
// The following type is available from the @types/semver package. | ||
[ | ||
'import {SemVer} from "semver"; type Test = SemVer;', | ||
{ from: 'package', name: 'SemVer', package: 'semver' }, | ||
], | ||
// The following type is available from the scoped @types/babel__code-frame package. | ||
[ | ||
'import {BabelCodeFrameOptions} from "@babel/code-frame"; type Test = BabelCodeFrameOptions;', | ||
{ | ||
from: 'package', | ||
name: 'BabelCodeFrameOptions', | ||
package: '@babel/code-frame', | ||
}, | ||
], | ||
])('matches a matching package specifier: %s', runTestPositive); | ||
it.each<[string, TypeOrValueSpecifier]>([ | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: 'Symbol', package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: ['Symbol', 'Checker'], package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: 'Node', package: 'other-package' }, | ||
], | ||
[ | ||
'import type {Node} from "typescript"; type Test = Node;', | ||
{ from: 'package', name: ['Node', 'Symbol'], package: 'other-package' }, | ||
], | ||
[ | ||
'interface Node {prop: string}; type Test = Node;', | ||
{ from: 'package', name: 'Node', package: 'typescript' }, | ||
], | ||
[ | ||
'import type {Node as TsNode} from "typescript"; type Test = TsNode;', | ||
{ from: 'package', name: 'TsNode', package: 'typescript' }, | ||
], | ||
])("doesn't match a mismatched lib specifier: %s", runTestNegative); | ||
it.each<[string, TypeOrValueSpecifier]>([ | ||
[ | ||
'interface Foo {prop: string}; type Test = Foo;', | ||