-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reorganize exports/types and nsExports/nsTypes issue types (resolves #…
…475)
- Loading branch information
Showing
33 changed files
with
353 additions
and
132 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/knip/fixtures/imports-namespace-with-nsexports/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export * as ReExported from './re-exported-module'; | ||
import * as NS from './namespace'; | ||
import * as NS2 from './namespace2'; | ||
import * as NS3 from './namespace3'; | ||
import * as NS4 from './namespace4'; | ||
import * as NS5 from './namespace5'; | ||
import * as NS6 from './namespace6'; | ||
import fn from 'external'; | ||
|
||
NS.identifier15; | ||
NS['identifier16']; | ||
NS.identifier17(); | ||
|
||
const { identifier18, identifier19, identifier20 } = NS2; | ||
|
||
NS2.identifier21.method(); | ||
|
||
function usage() { | ||
const hello = { NS3 }; | ||
} | ||
|
||
fn(NS4); | ||
|
||
const spread = { ...NS5 }; | ||
|
||
const assign = NS6; |
3 changes: 3 additions & 0 deletions
3
packages/knip/fixtures/imports-namespace-with-nsexports/namespace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const identifier15 = 1; | ||
export const identifier16 = 1; | ||
export const identifier17 = () => 1; |
4 changes: 4 additions & 0 deletions
4
packages/knip/fixtures/imports-namespace-with-nsexports/namespace2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const identifier18 = 1; | ||
export const identifier19 = 1; | ||
export const identifier20 = () => 1; | ||
export const identifier21 = { method: () => 1 }; |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/imports-namespace-with-nsexports/namespace3.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier31 = 31; | ||
export const identifier32 = 32; |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/imports-namespace-with-nsexports/namespace4.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier33 = 33; | ||
export const identifier34 = 34; |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/imports-namespace-with-nsexports/namespace5.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier35 = 35; | ||
export const identifier36 = 36; |
2 changes: 2 additions & 0 deletions
2
packages/knip/fixtures/imports-namespace-with-nsexports/namespace6.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier37 = 37; | ||
export const identifier38 = 38; |
8 changes: 8 additions & 0 deletions
8
packages/knip/fixtures/imports-namespace-with-nsexports/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@fixtures/imports-namespace-with-nsexports", | ||
"knip": { | ||
"include": [ | ||
"nsExports" | ||
] | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/knip/fixtures/imports-namespace-with-nsexports/re-exported-module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const myFunction = () => void 0; | ||
|
||
export default myFunction; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier31 = 31; | ||
export const identifier32 = 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier33 = 33; | ||
export const identifier34 = 34; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier35 = 35; | ||
export const identifier36 = 36; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const identifier37 = 37; | ||
export const identifier38 = 38; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,3 @@ | ||
{ | ||
"name": "@fixtures/namespace", | ||
"knip": { | ||
"entry": [ | ||
"index.ts" | ||
], | ||
"project": [ | ||
"*.ts" | ||
] | ||
} | ||
"name": "@fixtures/imports-namespace" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { SerializableImports } from '../types/imports.js'; | ||
|
||
export const getHasStrictlyNsReferences = (importsForExport: SerializableImports): [boolean, string?] => { | ||
if (!importsForExport || !importsForExport.hasStar || importsForExport.importedNs.size === 0) return [false]; | ||
let namespace; | ||
for (const ns of importsForExport.importedNs) { | ||
const hasNs = importsForExport.identifiers.has(ns); | ||
if (!hasNs) return [false, ns]; | ||
for (const id of importsForExport.identifiers) if (id.startsWith(ns + '.')) return [false, ns]; | ||
namespace = ns; | ||
} | ||
return [true, namespace]; | ||
}; | ||
|
||
export const getType = (hasOnlyNsReference: boolean, isType: boolean) => | ||
hasOnlyNsReference ? (isType ? 'nsTypes' : 'nsExports') : isType ? 'types' : 'exports'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.