Skip to content

Commit fd48a61

Browse files
authored
[TS] Fix #3973 Typescript imports file extension
1 parent 6ddbbed commit fd48a61

38 files changed

+89
-118
lines changed

src/Fable.Cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

20+
* [TS] Fix #3973 Typescript imports file extension (by @ncave)
2021
* [TS] Fix support for abstract classes and members (by @ncave)
2122
* [TS] Fix getters, setters, indexers in interfaces (by @ncave)
2223
* [TS] Enable typedArrays flag usage for TypeScript (by @ncave)

src/Fable.Cli/Pipeline.fs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,7 @@ module Js =
8282
type BabelWriter
8383
(com: Compiler, cliArgs: CliArgs, pathResolver: PathResolver, sourcePath: string, targetPath: string)
8484
=
85-
// In imports *.ts extensions have to be converted to *.js extensions instead
86-
let fileExt =
87-
let fileExt = cliArgs.CompilerOptions.FileExtension
88-
89-
if fileExt.EndsWith(".ts", StringComparison.Ordinal) then
90-
Path.ChangeExtension(fileExt, ".js")
91-
else
92-
fileExt
93-
85+
let fileExt = cliArgs.CompilerOptions.FileExtension
9486
let sourceDir = Path.GetDirectoryName(sourcePath)
9587
let targetDir = Path.GetDirectoryName(targetPath)
9688
let memoryStream = new IO.MemoryStream()

src/Fable.Compiler/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
### Fixed
1919

20+
* [TS] Fix #3973 Typescript imports file extension (by @ncave)
2021
* [TS] Fix support for abstract classes and members (by @ncave)
2122
* [TS] Fix getters, setters, indexers in interfaces (by @ncave)
2223
* [TS] Enable typedArrays flag usage for TypeScript (by @ncave)

src/Fable.Compiler/Library.fs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ type BabelWriter
3535
?fileExt: string
3636
)
3737
=
38-
// In imports *.ts extensions have to be converted to *.js extensions instead
39-
// TODO: incomplete
4038
let fileExt = Option.defaultValue ".js" fileExt
4139
let sourceDir = Path.GetDirectoryName(sourcePath)
4240
let targetDir = Path.GetDirectoryName(targetPath)

src/Fable.Transforms/Replacements.fs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,15 +1002,7 @@ let fableCoreLib (com: ICompiler) (ctx: Context) r t (i: CallInfo) (thisArg: Exp
10021002
let fixDynamicImportPath =
10031003
function
10041004
| Value(StringConstant path, r) when path.EndsWith(".fs", StringComparison.Ordinal) ->
1005-
// In imports *.ts extensions have to be converted to *.js extensions instead
10061005
let fileExt = com.Options.FileExtension
1007-
1008-
let fileExt =
1009-
if fileExt.EndsWith(".ts", StringComparison.Ordinal) then
1010-
Path.ChangeExtension(fileExt, ".js")
1011-
else
1012-
fileExt
1013-
10141006
Value(StringConstant(Path.ChangeExtension(path, fileExt)), r)
10151007
| path -> path
10161008

src/Fable.Transforms/Transforms.Util.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ module AST =
11301130
com.LibraryDir + "/" + moduleName' + ".py"
11311131
| Rust -> com.LibraryDir + "/" + moduleName + ".rs"
11321132
| Dart -> com.LibraryDir + "/" + moduleName + ".dart"
1133+
| TypeScript -> com.LibraryDir + "/" + moduleName + ".ts"
11331134
| _ -> com.LibraryDir + "/" + moduleName + ".js"
11341135

11351136
let makeImportUserGenerated r t (selector: string) (path: string) =

src/fable-compiler-js/src/app.fs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,6 @@ module Imports =
139139
importPath
140140

141141
type SourceWriter(sourcePath, targetPath, projDir, options: CmdLineOptions, fileExt: string, dedupTargetDir) =
142-
// In imports *.ts extensions have to be converted to *.js extensions instead
143-
let fileExt =
144-
if fileExt.EndsWith(".ts") then
145-
Path.ChangeExtension(fileExt, ".js")
146-
else
147-
fileExt
148-
149142
let sb = System.Text.StringBuilder()
150143
let mapGenerator = lazy (SourceMapSharp.SourceMapGenerator())
151144

src/fable-library-ts/Async.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { OperationCanceledException, Trampoline } from "./AsyncBuilder.js";
2-
import { Continuation, Continuations } from "./AsyncBuilder.js";
3-
import { Async, IAsyncContext, CancellationToken } from "./AsyncBuilder.js";
4-
import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.js";
5-
import { FSharpChoice$2_$union, Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.js";
6-
import { TimeoutException_$ctor } from "./System.js";
7-
import { Exception } from "./Util.js";
1+
import { OperationCanceledException, Trampoline } from "./AsyncBuilder.ts";
2+
import { Continuation, Continuations } from "./AsyncBuilder.ts";
3+
import { Async, IAsyncContext, CancellationToken } from "./AsyncBuilder.ts";
4+
import { protectedCont, protectedBind, protectedReturn } from "./AsyncBuilder.ts";
5+
import { FSharpChoice$2_$union, Choice_makeChoice1Of2, Choice_makeChoice2Of2 } from "./Choice.ts";
6+
import { TimeoutException_$ctor } from "./System.ts";
7+
import { Exception } from "./Util.ts";
88

99
function emptyContinuation<T>(_x: T) {
1010
// NOP

src/fable-library-ts/AsyncBuilder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Exception, ensureErrorOrException, IDisposable } from "./Util.js";
1+
import { Exception, ensureErrorOrException, IDisposable } from "./Util.ts";
22

33
export interface AsyncReplyChannel<Reply> {
44
reply(value: Reply): void

src/fable-library-ts/BigInt.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { FSharpRef } from "./Types.js";
2-
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.js";
3-
import { decimal, fromParts, truncate } from "./Decimal.js";
4-
import { Exception, bigintHash } from "./Util.js";
1+
import { FSharpRef } from "./Types.ts";
2+
import { int8, uint8, int16, uint16, int32, uint32, float16, float32, float64 } from "./Int32.ts";
3+
import { decimal, fromParts, truncate } from "./Decimal.ts";
4+
import { Exception, bigintHash } from "./Util.ts";
55

66
const isBigEndian = false;
77

0 commit comments

Comments
 (0)