Skip to content

Bug: Type is not assignable to type #1246

Closed as duplicate of#1080
Closed as duplicate of#1080
@mxschmitt

Description

@mxschmitt

The following works in tsc@latest but not with TypeScript Native.

Repro: https://github.com/mxschmitt/tsgo-native-yaml-repro

Error:

�[96msrc/index.ts�[0m:�[93m6�[0m:�[93m7�[0m - �[91merror�[0m�[90m TS2345: �[0mArgument of type 'typeof import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/index")' is not assignable to parameter of type 'typeof import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/index")'.
  Types of property 'Composer' are incompatible.
    Type 'typeof import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/compose/composer").Composer' is not assignable to type 'typeof import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/compose/composer").Composer'.
      Types of parameters 'options' and 'options' are incompatible.
        Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").ParseOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").DocumentOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").SchemaOptions | undefined' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").ParseOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").DocumentOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").SchemaOptions | undefined'.
          Type 'ParseOptions & DocumentOptions & SchemaOptions' is not assignable to type 'ParseOptions & DocumentOptions & SchemaOptions | undefined'.
            Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").ParseOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").DocumentOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/options").SchemaOptions' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").ParseOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").DocumentOptions & import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/options").SchemaOptions'.
              Type 'ParseOptions & DocumentOptions & SchemaOptions' is not assignable to type 'ParseOptions'.
                Types of property 'uniqueKeys' are incompatible.
                  Type 'boolean | ((a: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").ParsedNode, b: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").ParsedNode) => boolean) | undefined' is not assignable to type 'boolean | ((a: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").ParsedNode, b: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").ParsedNode) => boolean) | undefined'.
                    Type '(a: ParsedNode, b: ParsedNode) => boolean' is not assignable to type 'boolean | ((a: ParsedNode, b: ParsedNode) => boolean) | undefined'.
                      Type '(a: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").ParsedNode, b: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").ParsedNode) => boolean' is not assignable to type '(a: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").ParsedNode, b: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").ParsedNode) => boolean'.
                        Types of parameters 'a' and 'a' are incompatible.
                          Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").ParsedNode' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").ParsedNode'.
                            Type 'Parsed' is not assignable to type 'ParsedNode'.
                              Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Scalar").Scalar.Parsed' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Scalar").Scalar.Parsed'.
                                Types of property 'toJSON' are incompatible.
                                  Type '(arg?: any, ctx?: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext | undefined) => any' is not assignable to type '(arg?: any, ctx?: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext | undefined) => any'.
                                    Types of parameters 'ctx' and 'ctx' are incompatible.
                                      Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext | undefined' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext | undefined'.
                                        Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext'.
                                          Types of property 'anchors' are incompatible.
                                            Type 'Map<import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").Node, import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").AnchorData>' is not assignable to type 'Map<import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").Node, import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").AnchorData>'.
                                              Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").Node' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").Node'.
                                                Type 'Alias' is not assignable to type 'Node'.
                                                  Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Alias").Alias' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Alias").Alias'.
                                                    Types of property 'addToJSMap' are incompatible.
                                                      Type '((ctx: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext | undefined, map: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/YAMLMap").MapLike, value: unknown) => void) | undefined' is not assignable to type '((ctx: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext | undefined, map: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/YAMLMap").MapLike, value: unknown) => void) | undefined'.
                                                        Type '(ctx: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext | undefined, map: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/YAMLMap").MapLike, value: unknown) => void' is not assignable to type '(ctx: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext | undefined, map: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/YAMLMap").MapLike, value: unknown) => void'.
                                                          Types of parameters 'ctx' and 'ctx' are incompatible.
                                                            Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext | undefined' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext | undefined'.
                                                              Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").ToJSContext' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").ToJSContext'.
                                                                Types of property 'anchors' are incompatible.
                                                                  Type 'Map<import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").Node, import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/toJS").AnchorData>' is not assignable to type 'Map<import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").Node, import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/toJS").AnchorData>'.
                                                                    Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").Node' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").Node'.
                                                                      Type 'Alias' is not assignable to type 'Node'.
                                                                        Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Alias").Alias' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Alias").Alias'.
                                                                          The types returned by 'clone().toString' are incompatible between these types.
                                                                            Type '(ctx?: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/stringify/stringify").StringifyContext | undefined, onComment?: (() => void) | undefined, onChompKeep?: (() => void) | undefined) => string' is not assignable to type '(ctx?: import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/stringify/stringify").StringifyContext | undefined, onComment?: (() => void) | undefined, onChompKeep?: (() => void) | undefined) => string'.
                                                                              Types of parameters 'ctx' and 'ctx' are incompatible.
                                                                                Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/stringify/stringify").StringifyContext | undefined' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/stringify/stringify").StringifyContext | undefined'.
                                                                                  Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/stringify/stringify").StringifyContext' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/stringify/stringify").StringifyContext'.
                                                                                    The types of 'doc.contents' are incompatible between these types.
                                                                                      Type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml/dist/nodes/Node").Node | null' is not assignable to type 'import("/Users/maxschmitt/Developer/yaml-repro/node_modules/yaml2/dist/nodes/Node").Node | null'.
                                                                                        Type 'Alias' is not assignable to type 'Node | null'.
                                                                                          Type 'Alias' is not assignable to type 'Alias | Scalar<unknown> | YAMLMap<unknown, unknown> | YAMLSeq<unknown>'.

�[7m6�[0m yaml1(yaml2);
�[7m �[0m �[91m      ~~~~~�[0m

Found 1 error in src/index.ts�[90m:6�[0m

Is this intentional?

Metadata

Metadata

Assignees

Labels

Domain: Module ResolutionRelated to module resolution and module checker errors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions