@atlaspack/ts-utils 2.14.1-canary.26 → 2.14.1-canary.260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @atlaspack/ts-utils
2
2
 
3
+ ## 2.14.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572)]:
8
+ - @atlaspack/types-internal@2.20.0
9
+
10
+ ## 2.14.8
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies []:
15
+ - @atlaspack/types-internal@2.19.5
16
+
17
+ ## 2.14.7
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies []:
22
+ - @atlaspack/types-internal@2.19.4
23
+
24
+ ## 2.14.6
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies []:
29
+ - @atlaspack/types-internal@2.19.3
30
+
31
+ ## 2.14.5
32
+
33
+ ### Patch Changes
34
+
35
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
36
+
37
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
38
+ - @atlaspack/types-internal@2.19.2
39
+
40
+ ## 2.14.4
41
+
42
+ ### Patch Changes
43
+
44
+ - Updated dependencies []:
45
+ - @atlaspack/types-internal@2.19.1
46
+
47
+ ## 2.14.3
48
+
49
+ ### Patch Changes
50
+
51
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
52
+ - @atlaspack/types-internal@2.19.0
53
+
54
+ ## 2.14.2
55
+
56
+ ### Patch Changes
57
+
58
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
59
+
60
+ ## 2.14.1
61
+
62
+ ### Patch Changes
63
+
64
+ - [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
65
+ This has hopefully been fixed, so this change will force those packages to re-release.
66
+
3
67
  ## 2.14.0
4
68
 
5
69
  ### Minor Changes
@@ -14,10 +14,14 @@ function _path() {
14
14
  var _FSHost = require("./FSHost");
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  // eslint-disable-line import/no-extraneous-dependencies
17
+
17
18
  // eslint-disable-line import/no-extraneous-dependencies
19
+
18
20
  class CompilerHost extends _FSHost.FSHost {
19
21
  // workaround for https://github.com/microsoft/TypeScript/issues/39547
20
22
  redirectTypes = new Map();
23
+
24
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
21
25
  constructor(fs, ts, logger) {
22
26
  super(fs, ts);
23
27
  this.logger = logger;
@@ -27,7 +31,9 @@ class CompilerHost extends _FSHost.FSHost {
27
31
  if (contents && _path().default.basename(filePath) === 'package.json') {
28
32
  let json = JSON.parse(contents);
29
33
  if (json.types != null && json.source != null && !super.fileExists(_path().default.posix.join(_path().default.posix.dirname(filePath), json.types))) {
30
- let source = _path().default.posix.join(_path().default.posix.dirname(filePath), json.source);
34
+ let source = _path().default.posix.join(_path().default.posix.dirname(filePath),
35
+ // @ts-expect-error Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
36
+ json.source);
31
37
  let fakeTypes = source.slice(0, -_path().default.posix.extname(source).length) + '.d.ts';
32
38
  this.redirectTypes.set(fakeTypes, source);
33
39
  json.types = fakeTypes;
package/lib/FSHost.js CHANGED
@@ -13,7 +13,11 @@ function _path() {
13
13
  }
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  // eslint-disable-line import/no-extraneous-dependencies
16
+
16
17
  class FSHost {
18
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
19
+
20
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
17
21
  constructor(fs, ts) {
18
22
  this.fs = fs;
19
23
  this.ts = ts;
@@ -83,7 +87,6 @@ class FSHost {
83
87
  }
84
88
  }
85
89
  readDirectory(root, extensions, excludes, includes, depth) {
86
- // $FlowFixMe[prop-missing]
87
90
  return this.ts.matchFiles(root, extensions, excludes, includes, this.ts.sys.useCaseSensitiveFileNames, this.getCurrentDirectory(), depth, dirPath => this.getAccessibleFileSystemEntries(dirPath), filePath => this.realpath(filePath), dirPath => this.directoryExists(dirPath));
88
91
  }
89
92
  }
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.LanguageServiceHost = void 0;
7
7
  var _FSHost = require("./FSHost");
8
8
  // eslint-disable-line import/no-extraneous-dependencies
9
+
9
10
  // the typings from flow-typed define the ILanguageServiceHost interface as
10
11
  // having its methods as properties with arrow functions. These should probably
11
12
  // be methods instead.
12
- // $FlowFixMe[method-unbinding]
13
13
  class LanguageServiceHost extends _FSHost.FSHost {
14
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
14
15
  constructor(fs, ts, config) {
15
16
  super(fs, ts);
16
17
  this.config = config;
@@ -18,7 +19,6 @@ class LanguageServiceHost extends _FSHost.FSHost {
18
19
  }
19
20
  invalidate(fileName) {
20
21
  // When the typescript language server calls "getScriptVersion", it will normalize paths for cross-platform (e.g. C:\myFile.ts on Windows becomes C:/myFile.ts). We need to do the same thing.
21
- // $FlowFixMe getNormalizedAbsolutePath is missing from the flow-typed definition.
22
22
  const normalizedFileName = this.ts.getNormalizedAbsolutePath(fileName);
23
23
  const entry = this.files[normalizedFileName];
24
24
  if (entry) {
@@ -33,6 +33,7 @@ class LanguageServiceHost extends _FSHost.FSHost {
33
33
  return this.config.fileNames;
34
34
  }
35
35
  getScriptVersion(fileName) {
36
+ // @ts-expect-error string | undefined
36
37
  return this.files[fileName] && this.files[fileName].version.toString();
37
38
  }
38
39
  getScriptSnapshot(fileName) {
@@ -41,7 +42,6 @@ class LanguageServiceHost extends _FSHost.FSHost {
41
42
  }
42
43
  const content = this.readFile(fileName);
43
44
  if (content) {
44
- // $FlowFixMe
45
45
  return this.ts.ScriptSnapshot.fromString(content);
46
46
  }
47
47
  }
@@ -7,7 +7,9 @@ exports.ParseConfigHost = void 0;
7
7
  var _FSHost = require("./FSHost");
8
8
  // eslint-disable-line import/no-extraneous-dependencies
9
9
  // eslint-disable-line import/no-extraneous-dependencies
10
+
10
11
  class ParseConfigHost extends _FSHost.FSHost {
12
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
11
13
  constructor(fs, ts) {
12
14
  super(fs, ts);
13
15
  this.filesRead = new Set();
@@ -0,0 +1,19 @@
1
+ import type { FilePath, FileSystem, PluginLogger } from '@atlaspack/types-internal';
2
+ import type { CompilerOptions, SourceFile } from 'typescript';
3
+ import { ScriptTarget } from 'typescript';
4
+ import { FSHost } from './FSHost';
5
+ export declare class CompilerHost extends FSHost {
6
+ outputCode: string | null | undefined;
7
+ outputMap: string | null | undefined;
8
+ logger: PluginLogger;
9
+ redirectTypes: Map<FilePath, FilePath>;
10
+ constructor(fs: FileSystem, ts: TypeScriptModule, logger: PluginLogger);
11
+ readFile(filePath: FilePath): undefined | string;
12
+ fileExists(filePath: FilePath): boolean;
13
+ getSourceFile(filePath: FilePath, languageVersion: ScriptTarget[keyof ScriptTarget]): undefined | SourceFile;
14
+ getDefaultLibFileName(options: CompilerOptions): string;
15
+ writeFile(filePath: FilePath, content: string): void;
16
+ getCanonicalFileName(fileName: FilePath): FilePath;
17
+ useCaseSensitiveFileNames(): boolean;
18
+ getNewLine(): string;
19
+ }
@@ -0,0 +1,16 @@
1
+ import type { FileSystem, FilePath } from '@atlaspack/types-internal';
2
+ export declare class FSHost {
3
+ fs: FileSystem;
4
+ ts: TypeScriptModule;
5
+ constructor(fs: FileSystem, ts: TypeScriptModule);
6
+ getCurrentDirectory: () => FilePath;
7
+ fileExists(filePath: FilePath): boolean;
8
+ readFile(filePath: FilePath): undefined | string;
9
+ directoryExists(filePath: FilePath): boolean;
10
+ realpath(filePath: FilePath): FilePath;
11
+ getAccessibleFileSystemEntries(dirPath: FilePath): {
12
+ directories: Array<FilePath>;
13
+ files: Array<FilePath>;
14
+ };
15
+ readDirectory(root: FilePath, extensions?: ReadonlyArray<string>, excludes?: ReadonlyArray<string>, includes?: ReadonlyArray<string>, depth?: number): any;
16
+ }
@@ -0,0 +1,16 @@
1
+ import type { FileSystem, FilePath } from '@atlaspack/types-internal';
2
+ import type { CompilerOptions, LanguageServiceHost as ILanguageServiceHost, IScriptSnapshot, ParsedCommandLine } from 'typescript';
3
+ import { FSHost } from './FSHost';
4
+ export declare class LanguageServiceHost extends FSHost implements ILanguageServiceHost {
5
+ config: ParsedCommandLine;
6
+ files: Partial<Record<FilePath, {
7
+ version: number;
8
+ }>>;
9
+ constructor(fs: FileSystem, ts: TypeScriptModule, config: ParsedCommandLine);
10
+ invalidate(fileName: FilePath): void;
11
+ getScriptFileNames(): Array<string>;
12
+ getScriptVersion(fileName: FilePath): string;
13
+ getScriptSnapshot(fileName: string): IScriptSnapshot | undefined;
14
+ getCompilationSettings(): CompilerOptions;
15
+ getDefaultLibFileName(projectOptions: any): string;
16
+ }
@@ -0,0 +1,9 @@
1
+ import type { FileSystem, FilePath } from '@atlaspack/types-internal';
2
+ import type { ParseConfigHost as IParseConfigHost } from 'typescript';
3
+ import { FSHost } from './FSHost';
4
+ export declare class ParseConfigHost extends FSHost implements IParseConfigHost {
5
+ filesRead: Set<FilePath>;
6
+ useCaseSensitiveFileNames: boolean;
7
+ constructor(fs: FileSystem, ts: TypeScriptModule);
8
+ readFile(filePath: FilePath): undefined | string;
9
+ }
@@ -0,0 +1,5 @@
1
+ export { FSHost } from './FSHost';
2
+ export { CompilerHost } from './CompilerHost';
3
+ export { ParseConfigHost } from './ParseConfigHost';
4
+ export { LanguageServiceHost } from './LanguageServiceHost';
5
+ export { loadTSConfig } from './loadTSConfig';
@@ -0,0 +1,2 @@
1
+ import type { Config, PluginOptions } from '@atlaspack/types-internal';
2
+ export declare function loadTSConfig(config: Config, options: PluginOptions): Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/ts-utils",
3
- "version": "2.14.1-canary.26+c7726ccfb",
3
+ "version": "2.14.1-canary.260+dc6e4b2bb",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,12 +9,14 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/index.js",
13
- "source": "src/index.js",
12
+ "main": "./lib/index.js",
13
+ "source": "./src/index.ts",
14
+ "types": "./lib/index.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
19
+ "@atlaspack/types-internal": "2.14.1-canary.260+dc6e4b2bb",
18
20
  "nullthrows": "^1.1.1"
19
21
  },
20
22
  "devDependencies": {
@@ -24,5 +26,9 @@
24
26
  "typescript": ">=3.0.0"
25
27
  },
26
28
  "type": "commonjs",
27
- "gitHead": "c7726ccfbde03bad9f19e103d6b4ed0d279d837d"
28
- }
29
+ "scripts": {
30
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
31
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
32
+ },
33
+ "gitHead": "dc6e4b2bb99f371d225c296dbf96363fdac52333"
34
+ }
@@ -1,26 +1,30 @@
1
- // @flow
2
- import type {FileSystem} from '@atlaspack/fs';
3
- import type {FilePath, PackageJSON, PluginLogger} from '@atlaspack/types';
4
- import typeof TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import type {
2
+ FilePath,
3
+ FileSystem,
4
+ PackageJSON,
5
+ PluginLogger,
6
+ } from '@atlaspack/types-internal';
7
+ import TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
5
8
  import type {CompilerOptions, SourceFile} from 'typescript';
6
- import typeof {ScriptTarget} from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
9
+ import {ScriptTarget} from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
7
10
 
8
11
  import path from 'path';
9
12
  import {FSHost} from './FSHost';
10
13
 
11
14
  export class CompilerHost extends FSHost {
12
- outputCode: ?string;
13
- outputMap: ?string;
15
+ outputCode: string | null | undefined;
16
+ outputMap: string | null | undefined;
14
17
  logger: PluginLogger;
15
18
  // workaround for https://github.com/microsoft/TypeScript/issues/39547
16
19
  redirectTypes: Map<FilePath, FilePath> = new Map();
17
20
 
21
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
18
22
  constructor(fs: FileSystem, ts: TypeScriptModule, logger: PluginLogger) {
19
23
  super(fs, ts);
20
24
  this.logger = logger;
21
25
  }
22
26
 
23
- readFile(filePath: FilePath): void | string {
27
+ readFile(filePath: FilePath): undefined | string {
24
28
  let contents = super.readFile(filePath);
25
29
  if (contents && path.basename(filePath) === 'package.json') {
26
30
  let json: PackageJSON = JSON.parse(contents);
@@ -31,7 +35,11 @@ export class CompilerHost extends FSHost {
31
35
  path.posix.join(path.posix.dirname(filePath), json.types),
32
36
  )
33
37
  ) {
34
- let source = path.posix.join(path.posix.dirname(filePath), json.source);
38
+ let source = path.posix.join(
39
+ path.posix.dirname(filePath),
40
+ // @ts-expect-error Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
41
+ json.source,
42
+ );
35
43
  let fakeTypes =
36
44
  source.slice(0, -path.posix.extname(source).length) + '.d.ts';
37
45
  this.redirectTypes.set(fakeTypes, source);
@@ -55,8 +63,8 @@ export class CompilerHost extends FSHost {
55
63
 
56
64
  getSourceFile(
57
65
  filePath: FilePath,
58
- languageVersion: $Values<ScriptTarget>,
59
- ): void | SourceFile {
66
+ languageVersion: ScriptTarget[keyof ScriptTarget],
67
+ ): undefined | SourceFile {
60
68
  let redirect = this.redirectTypes.get(filePath);
61
69
  if (redirect != null) {
62
70
  const sourceText = this.readFile(redirect);
@@ -1,13 +1,13 @@
1
- // @flow
2
- import type {FileSystem} from '@atlaspack/fs';
3
- import type {FilePath} from '@atlaspack/types';
4
- import typeof TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import type {FileSystem, FilePath} from '@atlaspack/types-internal';
2
+ import TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
5
3
  import path from 'path';
6
4
 
7
5
  export class FSHost {
8
6
  fs: FileSystem;
7
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
9
8
  ts: TypeScriptModule;
10
9
 
10
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
11
11
  constructor(fs: FileSystem, ts: TypeScriptModule) {
12
12
  this.fs = fs;
13
13
  this.ts = ts;
@@ -20,15 +20,15 @@ export class FSHost {
20
20
  fileExists(filePath: FilePath): boolean {
21
21
  try {
22
22
  return this.fs.statSync(filePath).isFile();
23
- } catch (err) {
23
+ } catch (err: any) {
24
24
  return false;
25
25
  }
26
26
  }
27
27
 
28
- readFile(filePath: FilePath): void | string {
28
+ readFile(filePath: FilePath): undefined | string {
29
29
  try {
30
30
  return this.fs.readFileSync(filePath, 'utf8');
31
- } catch (err) {
31
+ } catch (err: any) {
32
32
  if (err.code === 'ENOENT') {
33
33
  return undefined;
34
34
  }
@@ -40,7 +40,7 @@ export class FSHost {
40
40
  directoryExists(filePath: FilePath): boolean {
41
41
  try {
42
42
  return this.fs.statSync(filePath).isDirectory();
43
- } catch (err) {
43
+ } catch (err: any) {
44
44
  return false;
45
45
  }
46
46
  }
@@ -48,26 +48,26 @@ export class FSHost {
48
48
  realpath(filePath: FilePath): FilePath {
49
49
  try {
50
50
  return this.fs.realpathSync(filePath);
51
- } catch (err) {
51
+ } catch (err: any) {
52
52
  return filePath;
53
53
  }
54
54
  }
55
55
 
56
- getAccessibleFileSystemEntries(dirPath: FilePath): {|
57
- directories: Array<FilePath>,
58
- files: Array<FilePath>,
59
- |} {
56
+ getAccessibleFileSystemEntries(dirPath: FilePath): {
57
+ directories: Array<FilePath>;
58
+ files: Array<FilePath>;
59
+ } {
60
60
  try {
61
61
  let entries = this.fs.readdirSync(dirPath || '.').sort();
62
- let files = [];
63
- let directories = [];
62
+ let files: Array<FilePath> = [];
63
+ let directories: Array<FilePath> = [];
64
64
  for (let entry of entries) {
65
65
  let filePath = path.join(dirPath, entry);
66
66
 
67
67
  let stat;
68
68
  try {
69
69
  stat = this.fs.statSync(filePath);
70
- } catch (e) {
70
+ } catch (e: any) {
71
71
  continue;
72
72
  }
73
73
 
@@ -79,19 +79,18 @@ export class FSHost {
79
79
  }
80
80
 
81
81
  return {files, directories};
82
- } catch (err) {
82
+ } catch (err: any) {
83
83
  return {files: [], directories: []};
84
84
  }
85
85
  }
86
86
 
87
87
  readDirectory(
88
88
  root: FilePath,
89
- extensions?: $ReadOnlyArray<string>,
90
- excludes?: $ReadOnlyArray<string>,
91
- includes?: $ReadOnlyArray<string>,
89
+ extensions?: ReadonlyArray<string>,
90
+ excludes?: ReadonlyArray<string>,
91
+ includes?: ReadonlyArray<string>,
92
92
  depth?: number,
93
93
  ): any {
94
- // $FlowFixMe[prop-missing]
95
94
  return this.ts.matchFiles(
96
95
  root,
97
96
  extensions,
@@ -100,9 +99,9 @@ export class FSHost {
100
99
  this.ts.sys.useCaseSensitiveFileNames,
101
100
  this.getCurrentDirectory(),
102
101
  depth,
103
- (dirPath) => this.getAccessibleFileSystemEntries(dirPath),
104
- (filePath) => this.realpath(filePath),
105
- (dirPath) => this.directoryExists(dirPath),
102
+ (dirPath: any) => this.getAccessibleFileSystemEntries(dirPath),
103
+ (filePath: any) => this.realpath(filePath),
104
+ (dirPath: any) => this.directoryExists(dirPath),
106
105
  );
107
106
  }
108
107
  }
@@ -1,7 +1,5 @@
1
- // @flow
2
- import type {FileSystem} from '@atlaspack/fs';
3
- import type {FilePath} from '@atlaspack/types';
4
- import typeof TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import type {FileSystem, FilePath} from '@atlaspack/types-internal';
2
+ import TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
5
3
  import type {
6
4
  CompilerOptions,
7
5
  LanguageServiceHost as ILanguageServiceHost,
@@ -13,14 +11,21 @@ import {FSHost} from './FSHost';
13
11
  // the typings from flow-typed define the ILanguageServiceHost interface as
14
12
  // having its methods as properties with arrow functions. These should probably
15
13
  // be methods instead.
16
- // $FlowFixMe[method-unbinding]
17
14
  export class LanguageServiceHost
18
15
  extends FSHost
19
16
  implements ILanguageServiceHost
20
17
  {
21
18
  config: ParsedCommandLine;
22
- files: {|[key: FilePath]: {|version: number|}|};
19
+ files: Partial<
20
+ Record<
21
+ FilePath,
22
+ {
23
+ version: number;
24
+ }
25
+ >
26
+ >;
23
27
 
28
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
24
29
  constructor(fs: FileSystem, ts: TypeScriptModule, config: ParsedCommandLine) {
25
30
  super(fs, ts);
26
31
  this.config = config;
@@ -29,7 +34,6 @@ export class LanguageServiceHost
29
34
 
30
35
  invalidate(fileName: FilePath) {
31
36
  // When the typescript language server calls "getScriptVersion", it will normalize paths for cross-platform (e.g. C:\myFile.ts on Windows becomes C:/myFile.ts). We need to do the same thing.
32
- // $FlowFixMe getNormalizedAbsolutePath is missing from the flow-typed definition.
33
37
  const normalizedFileName = this.ts.getNormalizedAbsolutePath(fileName);
34
38
  const entry = this.files[normalizedFileName];
35
39
 
@@ -47,10 +51,11 @@ export class LanguageServiceHost
47
51
  }
48
52
 
49
53
  getScriptVersion(fileName: FilePath): string {
54
+ // @ts-expect-error string | undefined
50
55
  return this.files[fileName] && this.files[fileName].version.toString();
51
56
  }
52
57
 
53
- getScriptSnapshot(fileName: string): IScriptSnapshot | void {
58
+ getScriptSnapshot(fileName: string): IScriptSnapshot | undefined {
54
59
  if (!this.fileExists(fileName)) {
55
60
  return;
56
61
  }
@@ -58,7 +63,6 @@ export class LanguageServiceHost
58
63
  const content = this.readFile(fileName);
59
64
 
60
65
  if (content) {
61
- // $FlowFixMe
62
66
  return this.ts.ScriptSnapshot.fromString(content);
63
67
  }
64
68
  }
@@ -1,7 +1,5 @@
1
- // @flow
2
- import type {FileSystem} from '@atlaspack/fs';
3
- import type {FilePath} from '@atlaspack/types';
4
- import typeof TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
1
+ import type {FileSystem, FilePath} from '@atlaspack/types-internal';
2
+ import TypeScriptModule from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
5
3
  import type {ParseConfigHost as IParseConfigHost} from 'typescript'; // eslint-disable-line import/no-extraneous-dependencies
6
4
  import {FSHost} from './FSHost';
7
5
 
@@ -9,13 +7,14 @@ export class ParseConfigHost extends FSHost implements IParseConfigHost {
9
7
  filesRead: Set<FilePath>;
10
8
  useCaseSensitiveFileNames: boolean;
11
9
 
10
+ // @ts-expect-error Cannot use namespace 'TypeScriptModule' as a type.
12
11
  constructor(fs: FileSystem, ts: TypeScriptModule) {
13
12
  super(fs, ts);
14
13
  this.filesRead = new Set();
15
14
  this.useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
16
15
  }
17
16
 
18
- readFile(filePath: FilePath): void | string {
17
+ readFile(filePath: FilePath): undefined | string {
19
18
  this.filesRead.add(filePath);
20
19
  return super.readFile(filePath);
21
20
  }
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  export {FSHost} from './FSHost';
3
2
  export {CompilerHost} from './CompilerHost';
4
3
  export {ParseConfigHost} from './ParseConfigHost';
@@ -1,5 +1,4 @@
1
- // @flow
2
- import type {Config, PluginOptions} from '@atlaspack/types';
1
+ import type {Config, PluginOptions} from '@atlaspack/types-internal';
3
2
  import {ParseConfigHost} from './ParseConfigHost';
4
3
  import path from 'path';
5
4
  import nullthrows from 'nullthrows';
@@ -8,7 +7,7 @@ import ts from 'typescript';
8
7
  export async function loadTSConfig(
9
8
  config: Config,
10
9
  options: PluginOptions,
11
- ): any {
10
+ ): Promise<any> {
12
11
  let configResult = await config.getConfig(['tsconfig.json']);
13
12
  if (!configResult) {
14
13
  return;
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }