Skip to content

Add object type support #58

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions samples/extendsobject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// copy from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/lodash/index.d.ts
declare interface LoDashStatic {
at<T extends object>();
};

13 changes: 13 additions & 0 deletions samples/extendsobject.ts.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import scala.scalajs.js
import js.annotation._
import js.|

package extendsobject {

@js.native
trait LoDashStatic extends js.Object {
def at[T <: js.Object](): js.Dynamic = js.native
}

}
1 change: 1 addition & 0 deletions src/main/scala/org/scalajs/tools/tsimporter/Importer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class Importer(val output: java.io.PrintWriter) {
val baseTypeRef = base match {
case TypeName("Array") => QualifiedName.Array
case TypeName("Function") => QualifiedName.FunctionBase
case TypeName("object") => QualifiedName.Object
case TypeNameName(name) => QualifiedName(name)
case QualifiedTypeName(qualifier, TypeNameName(name)) =>
val qual1 = qualifier map (x => Name(x.name))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ object QualifiedName {
val Array = scala_js dot Name("Array")
val Dictionary = scala_js dot Name("Dictionary")
val FunctionBase = scala_js dot Name("Function")
val Object = scala_js dot Name("Object")
def Function(arity: Int) = scala_js dot Name("Function"+arity)
def Tuple(arity: Int) = scala_js dot Name("Tuple"+arity)
val Union = scala_js dot Name("|")
Expand Down